/*
 * @Author: sunfuping
 * @Date: 2019-09-09 19:35:52
 * @Last Modified by: sunfuping
 * @Last Modified time: 2019-10-28 16:03:46
 */

<template>
    <div class="dayBox">
        <ul class="day">
            <div v-for="(item,index) in items" :key="index" >
                <li v-if='item.today == 1' class="gay">
                    <div>{{item.week}}</div>
                    <div>{{item.day}}</div>
                </li>
                <li v-else   @click="addClass(index,item)" :class="{'active':position == index}"  htmdEvt="productCalendar_changeDay">
                    <div>{{item.week}}</div>
                    <div>{{item.day}}</div>
                </li>
            </div>
        </ul>
        <div class="monthBox">
            <div class="month">{{tmonth}}月{{chooseDay}}日</div>
        </div>
	</div>
</template>

<script  type="text/javascript">

import "./calendar.less";
// import tipAction from "@common/components/otherComponents/tipAction/tipAction";
// import tipAction1 from "@common/components/otherComponents/tipActionOther/tipActionOther";
// import splitUrl from "@common/js/splitUrl.js";
// import  "@common/components/otherComponents/tipActionOther/tipActionOther.less";
export default {
    name: "calendar",
    data() {
        return {
            position: '',
            tmonth:'10',
            chooseDay: '13',
            items: [
                // {month:'9',day: '10',week:'周一',today:'1'},
                // {month:'9',day: '11',week:'周二',today:'1'},
                // {month:'9',day: '12',week:'周三',today:'1'},
                // {month:'9',day: '13',week:'周四',today:'2'},
                // {month:'9',day: '14',week:'周五',today:'3'},
                // {month:'9',day: '15',week:'周六',today:'3'},
                // {month:'10',day: '1',week:'周日',today:'3'}
            ]
        };
    },
    created(){
        this.initDate();
    },
    mounted () {

    },
    methods: {
        addClass(index,item) {
            this.position = index;
            this.chooseDay = item.day;
            this.tmonth = item.month;
            let obj = {position: this.position, item: item};
            this.$emit("passtoparent",obj);
        },
        initDate() {
            this.$axiosHttp.http({
                    name:'',
                    url: apiUrl.getThisWeekApi,
                    needFailCallback: true,
                    method: 'POST',
                    params: {}
            }, (res) => {
                let data = res.data.data;

                for(let i in data) {
                    if(data[i].today == 2) {
                        this.position = i;
                        this.chooseDay = data[i].day;
                        this.tmonth = data[i].month;
                        var obj = {position: this.position, item: data[i]};
                        this.$emit("passtoparent",obj);
                        // this.$emit("passtoparent", data[i]);
                    }
                };
                this.items = data;
            },res => {
                tipAction(res.data.message);
            });
        },

    },



};
</script>
